﻿@using KelonProud
@using KelonProud.Mvc.Models
@model KelonProud.Administration.Dtos.UserModifyPwdInPut

@{
    Layout = "~/Views/Shared/_EditMaster.cshtml";
}

<style>
    @@media(min-width:300px) {
        .form-horizontal .control-label {
            padding-top: 7px;
            margin-bottom: 0;
            text-align: right;
        }

        .col-sm-3 {
            width: 25%;
            float: left;
        }

        .col-sm-9 {
            width: 75%;
            float: left;
        }
    }
</style>

<div class="box from-box modal-box">
    <form class="form-horizontal" id="EditForm" name="EditForm" validate method="post" role="form">
        <div class="box-body">
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane animated fadeIn active" id="edit-navigation-details">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">原密码</label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(f => f.OldPassWord, new { @class = "form-control validate", placeholder = "请输入原使用密码" })
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">新密码</label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(f => f.NewPassWord, new { @class = "form-control validate", placeholder = "请输入新的密码" })
                            <span class="help-block m-b-none">密码必须以字母+数字组成，并且密码长度为6-15个字符</span>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">重复密码</label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(f => f.NewPassWordR, new { @class = "form-control validate", placeholder = "请再次输入新密码" })
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @Html.Partial("~/Views/Shared/Modals/_ModalFooterWithSaveAndCancel.cshtml")
    </form>
</div>


@section scripts{
    <script>
        function saveFormEvent(_$form) {
            var _navService = abp.services.admin.user;
            var user = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js

            if (user.NewPassWord !== user.NewPassWordR) {
                abp.message.error("两次输入密码不一致");
            } else {
                abp.ui.setBusy(_$form);
                _navService.changePassword(user).done(function() {
                    abp.notify.success("密码修改成功！");
                    DiyWindow.closeModal();
                }).always(function() {
                    abp.ui.clearBusy(_$form);
                });
            }
        }
    </script>
}